<template>
  <div>
    <Menu mode="horizontal" @on-select='lowerStep' :active-name="modaleshow">
      <MenuItem name="1">基础标准管理</MenuItem>
      <MenuItem name="2">现场标准管理</MenuItem>
      <MenuItem name="3">班组标准管理</MenuItem>
    </Menu>

    <Form :label-width="100" ref="form1" style="margin-top: 10px" :model="form1">
      <div v-if="switchFlag">
        <Row :gutter="16" class="query-form">
          <i-col span="8">
            <FormItem label="问题描述：">
              <Input type="text" v-model="form1.rpoblemDesc"/>
            </FormItem>
          </i-col>
          <i-col span="8">
            <FormItem label="审计专家：">
              <Input type="text" v-model="form1.auditorName"/>
            </FormItem>
          </i-col>
          <Col span="8">
            <FormItem label="项目大类：">
              <Input type="text" v-model="form1.categoryName"/>
            </FormItem>
          </Col>
        </Row>
        <Row :gutter="16" class="query-form2">

          <Col span="8">
            <FormItem label="项目：">
              <Input type="text" v-model="form1.categoryProjectName"/>
            </FormItem>
          </Col>

          <i-col span="8" offset="8">
            <div style="float: right;">
              <Button class="ivu-btn-query" icon="md-search" @click="querySlect">查询</Button>
              <Button class="ivu-btn-reset" style="margin-left: 10px" @click="reset">重置</Button>
              <Button @click="switchQuery(false)" style="margin-left: 10px" class="ivu-btn-switch2" type="text">收起
                <Icon type="ios-arrow-up"/>
              </Button>
            </div>
          </i-col>
        </Row>
      </div>

      <div v-else>
        <Row :gutter="16" class="query-form2">
          <i-col span="8">
            <FormItem label="问题描述：">
              <Input type="text" v-model="form1.rpoblemDesc"/>
            </FormItem>
          </i-col>
          <i-col span="8">
            <FormItem label="审计专家：">
              <Input type="text" v-model="form1.auditorName"/>
            </FormItem>
          </i-col>

          <i-col span="8">
            <div style="float: right;">
              <Button class="ivu-btn-query" icon="md-search" @click="querySlect">查询</Button>
              <Button class="ivu-btn-reset" style="margin-left: 10px" @click="reset">重置</Button>
              <Button @click="switchQuery(true)" style="margin-left: 5px" class="ivu-btn-switch2" type="text">展开
                <Icon type="ios-arrow-down"/>
              </Button>
            </div>
          </i-col>
        </Row>
      </div>
      <Row class="query-form">
        <Col span="24">
          <Alert
              v-if="this.currentUser.userRole.find(obj => obj.roleId == 'dda573b123f9472d95ba3063b25133f7') != undefined"
              banner type="warning">被审计单位：{{ auditMod.auditName }},最终得分：{{ auditMod.finalScore }}
          </Alert>
        </Col>
      </Row>
      <Row class="query-form">
        <Col span="24">
          <!--          <Button size="large" class="ivu-btn-add" icon="md-add" @click="openSelect">新增</Button>-->
          <Button size="large" class="ivu-btn-add" icon="md-cloud-download" @click="downloadFile">问题清单导出</Button>
          <Button size="large" class="ivu-btn-add" icon="md-cloud-download" @click="downloadFileMod">审计标准裁剪导出</Button>
          <Button size="large" class="ivu-btn-add" icon="md-cloud-download"
                  v-if="missionModel.roleType == '1'||currentUser.loginId == this.Common.admin"
                  @click="downloadFileRank">分值分布导出
          </Button>
          <Button size="large" class="ivu-btn-add" icon="md-home" @click="back">返回</Button>

          <!--          <Button size="large" class="ivu-btn-add" icon="md-arrow-round-down" @click="queryAdminMessage">指派整改</Button>-->

        </Col>
      </Row>
    </Form>

    <Table ref='table' :height="tableHeight" class="table" no-data-text="没有查询到相关数据！" :loading="buttonLoading"
           size="small"
           highlight-row stripe border :columns="columns1" width="100%" :data="dataTable"
           @on-selection-change="reportSelect" :span-method="handleSpan">
      <template slot-scope="{ row, index }" slot="rpoblemDesc">
        <Input type="textarea" :autosize="{minRows:2,maxRows:5}" v-model="dataTable[index].rpoblemDesc"></Input>
      </template>
      <template slot-scope="{ row, index }" slot="auditScore">
        <InputNumber min='0' :max="row.factorScore == 0? 99999:row.factorScore" v-model="dataTable[index].auditScore"></InputNumber>
      </template>
    </Table>

    <Row style="margin-right:10px;">
      <Col span="24">
        <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
              @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
              show-total show-sizer show-elevator/>
      </Col>
    </Row>

    <Modal title="审计问题详情" :transfer=false v-model="model3" class="modal-view-detail" :width=900 :styles="{top: '10px'}">
      <Form ref="viewForm" :label-width="100">
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计任务：">
              {{ showdata.planTaskName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计单位：">
              {{ showdata.auditedOrgName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计专家：">
              {{ showdata.auditorName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计时间：" prop="auditTime">
              {{ showdata.auditTime ? this.formatDate(new Date(showdata.auditTime), 'yyyy-MM-dd') : '' }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="项目：">
              {{ showdata.factorName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计标准：">
              {{ showdata.executorName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="审计内容：">
              {{ showdata.subitemName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="扣分：" prop="auditScore">
              {{ showdata.auditScore }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="项目分值：">
              {{ showdata.factorScore }}
            </FormItem>
          </Col>
        </Row>

        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题描述：" prop="rpoblemDesc">
              {{ showdata.rpoblemDesc }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题图片:">
              <div class="demo-upload-list" style="display:inline;margin:2px" v-for="item in form1datacopy.upLoadList1"
                   :key="item.id">
                <img style="width:50px;height:50px;" @click="handleView(item.name,item.url)" :src="item.url">
              </div>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="音频:">
              <div class="demo-upload-list" style="display:inline;margin:2px" v-for="item in auditList"
                   :key="item.id">
                <Icon size="20" :type="audio" @click="play(item.url,showdata.amr)"/>
              </div>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="创建人：" prop="planStart">
              {{ showdata.createUserName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="创建时间：" prop="planEnd">
              {{ showdata.createDate }}
            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="onCancel">关闭</Button>
      </div>
    </Modal>
    <Modal title="审计任务选择" :transfer=false footer-hide v-model="missionSelectModal" :width=800>
      <missionSelectForPro ref="selMission" @selectMission="selectMission" :audit-state="0">
      </missionSelectForPro>
    </Modal>
    <Modal title="审计问题修改" :transfer=false v-model="model12" :width=800>
      <Form ref="viewForm" :label-width="100" :rules="ruleCustom">
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计任务：">
              {{ form1datacopy.planTaskName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计单位：">
              {{ form1datacopy.auditedOrgName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计专家：">
              {{ form1datacopy.auditorName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计时间：" prop="auditTime">
              <DatePicker type="date" format="yyyy-MM-dd" placeholder="请选择登陆时间" style="width: 100%"
                          v-model="form1datacopy.auditTime"></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="项目：">
              {{ form1datacopy.factorName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计标准：">
              {{ form1datacopy.executorName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="审计内容：">
              {{ form1datacopy.subitemName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="扣分：" prop="auditScore">
              <InputNumber style="width:100%" min="1" :max="form1datacopy.factorScore"
                           v-model="form1datacopy.auditScore"></InputNumber>
            </FormItem>
          </Col>

          <Col span="11">
            <FormItem label="项目分值：">
              <Input style="width:100%" v-model="form1datacopy.factorScore" readonly></Input>
            </FormItem>
          </Col>

        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="问题状态:">
              <Select label-in-value v-model="form1datacopy.problemState" @on-change="problemStateSelect">
                <Option value="0">待确认</Option>
                <Option value="1">已确认</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="11">

          </Col>
        </Row>

        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题描述：" prop="rpoblemDesc">
              <Input v-model="form1datacopy.rpoblemDesc" type="textarea" :rows="3"/>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题图片:">
              <!--<div class="demo-upload-list" style="display:inline;margin:2px" v-for="item in upLoadList1" :key="item.id">
                  <img style="width:50px;height:50px;" :src="item.url" @click="handleView(item.name,item.url)" >

              </div>-->
              <div>
                <Upload ref="upload"
                        :before-upload="beforeUpload"
                        :show-upload-list="true"
                        :max-size="10240"
                        multiple
                        type="drag"
                        :action="fileUrl">
                  <div style="padding: 10px">
                    <Icon type="ios-cloud-upload" size="40" style="color: #3399ff"></Icon>
                    <p>点击将文件拖拽到这里上传</p>
                    <!--<span style="font-size:8px;color: #797a64">支持扩展名：.docx .pdf</span>-->
                  </div>
                </Upload>
              </div>
              <div v-if="upLoadList1.length > 0">
                <div v-for="item in upLoadList1" :key='item.id'>
                  <a @click="downloadFiles(form1datacopy.problemId,item)"><span
                      style="color: #3399ff;margin-left: 5px"> {{ item.fileName }}</span>
                  </a>
                  <a @click="remove1(form1datacopy.problemId, item.id)"><span
                      style="color: #3399ff;margin-left: 5px">删除</span>
                  </a>
                </div>
              </div>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="创建人：" prop="planStart">
              {{ form1datacopy.createUserName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="创建时间：" prop="planEnd">
              {{ form1datacopy.createDate }}
            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="submit('viewForm')" :loading="submitLoading">确定</Button>
        <Button class='ivu-btn-cancel' @click="handleCancel">取消</Button>
      </div>
    </Modal>
    <Modal title="图片上传" :transfer=false footer-hide v-model="modelupload" :width=600>
      <Form ref="dataForm" :label-width="100">
        <Row type="flex" justify="space-around" class="code-row-bg" style="margin-top: 10px">
          <Col span="23">
            <FormItem label="上传图片：">
              <div class="demo-upload-list" v-for="item in form1datacopy.upLoadList1" :key="item.id">
                <img :src="item.picture">
                <div class="demo-upload-list-cover">
                  <Icon type="ios-eye-outline" @click.native="handleView(item.name,item.url)"></Icon>
                  <Icon type="ios-trash-outline" @click.native="remove1(form1datacopy.problemId, item.id)"></Icon>
                </div>
              </div>
              <div style='display:flex;flex-direction: column;' >
                <Upload
                    ref="upload"
                    :show-upload-list="true"
                    :format="['jpg','jpeg','png','gif']"
                    accept="image/jpg, image/jpeg,image/png,image/gif,image/bmp"
                    :max-size="10240"
                    :before-upload="beforeUpload"
                    multiple
                    type="drag"
                    :action="upUrl"
                    style="display: inline-block;">
                  <div style="height:58px;line-height: 58px;">
                    <Icon type="ios-camera" size="20"></Icon>
                  </div>
                </Upload>
                <div v-for="(item, index) in fileList">
                    <span>文件: {{ item.name }}</span>
                    <a href="javascript:;"  @click="delectFile(item.name)">X</a>
                    <Progress  :percent="filePercent[index]"></Progress>
                </div>
                <Button type="success" @click="handUpload">上传</Button>
              </div>
              <Modal title="View Image" v-model="visible">
                <img :src="viewUrl" v-if="visible" style="width: 100%">
                <div slot="footer">
                  <Button type="primary" class='ivu-btn-save' @click="visible=false">关闭</Button>
                </div>
              </Modal>
            </FormItem>
          </Col>
        </Row>
      </Form>
    </Modal>
    <Modal title="审计图片上传" :transfer=false v-model="modelupload1" :width=800>
      <Form ref="viewForm" :label-width="100">
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题照片：">
              <div>
                <Upload ref="upload"
                        :before-upload="beforeUpload"
                        :show-upload-list="true"
                        :max-size="10240"
                        multiple
                        type="drag"
                        :action="fileUrl">
                  <div style="padding: 10px">
                    <Icon type="ios-cloud-upload" size="40" style="color: #3399ff"></Icon>
                    <p>点击将文件拖拽到这里上传</p>
                    <!--<span style="font-size:8px;color: #797a64">支持扩展名：.docx .pdf</span>-->
                  </div>
                </Upload>
              </div>
              <div v-for="item in form1datacopy.upLoadList1" :key='item.id'>
                <router-link target="_blank" :to="{path:'/imgDetails',query:{id:item.id}}">
                  <img :src="item.picture" alt="" style="width: 50px;height: 50px;">
                </router-link>
                <a @click="downloadFiles(form1datacopy.problemId,item)"><span
                    style="color: #3399ff;margin-left: 5px"> {{ item.fileName }}</span>
                </a>
                <a @click="remove1(form1datacopy.problemId, item.id)"><span
                    style="color: #3399ff;margin-left: 5px">删除</span>
                </a>
              </div>

            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button class='ivu-btn-cancel' @click="modelupload=false;">关闭</Button>
      </div>
    </Modal>
    <Modal title="审计问题新增" :transfer=false v-model="model11" :width=900>
      <Form ref="form1datacopy" :model="form1datacopy" :rules="ruleCustom" label-position="top">
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计任务：">
              <Input v-model="form1datacopy.planTaskName" :readonly="true"/>
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计单位：">
              <Input v-model="form1datacopy.auditedOrgName" :readonly="true"/>
            </FormItem>
          </Col>
        </Row>

        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计专家：" prop="auditorId">
              <Input v-model="form1datacopy.auditorName" :readonly="true"/>
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计时间：" prop="auditTime">
              <DatePicker type="date" format="yyyy-MM-dd" placeholder="请选择登陆时间" style="width: 100%;"
                          v-model="form1datacopy.auditTime"></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="审计项目：" prop="factorName">
              <Input type="text" v-model="form1datacopy.factorName" readonly>
                <Button slot="append" @click="openTempSelector()" icon="ios-search"></Button>
              </Input>
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="审计标准：" prop="executorName">
              <Input type="text" v-model="form1datacopy.executorName" readonly/>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="审计内容：" prop="subitemId">
              <Select v-model="form1datacopy.subitemId" style="width:100%" label-in-value @on-change="checkSubitemId">
                <Option v-for="item in contentList" :value="item.id" :key="item.id" :title="item.auditContent">
                  {{ item.title }}
                </Option>
              </Select>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="扣分：" prop="auditScore">
              <InputNumber style="width:100%" min="1" :max="form1datacopy.factorScore"
                           v-model="form1datacopy.auditScore"></InputNumber>
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="项目分值：">
              <Input style="width:100%" v-model="form1datacopy.factorScore" readonly></Input>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="问题状态:">
              <Select label-in-value v-model="form1datacopy.problemState" @on-change="problemStateSelect">
                <Option value="0">待确认</Option>
                <Option value="1">已确认</Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="11">
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题描述：" prop="rpoblemDesc">
              <Input v-model="form1datacopy.rpoblemDesc" type="textarea" :rows="3"/>
            </FormItem>
          </Col>
        </Row>

        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="问题照片：">
              <div>
                <Upload ref="upload"
                        :before-upload="beforeUpload"
                        :show-upload-list="true"
                        :max-size="10240"
                        multiple
                        type="drag"
                        :action="fileUrl">
                  <div style="padding: 10px">
                    <Icon type="ios-cloud-upload" size="40" style="color: #3399ff"></Icon>
                    <p>点击将文件拖拽到这里上传</p>
                    <!--<span style="font-size:8px;color: #797a64">支持扩展名：.docx .pdf</span>-->
                  </div>
                </Upload>
              </div>

              <div v-if="upLoadList1.length > 0">
                <div v-for="item in upLoadList1" :key='item.id'>
                  <router-link target="_blank" :to="{path:'/imgDetails',query:{id:item.id}}">
                    <img :src="item.picture" alt="" style="width: 50px;height: 50px;">
                  </router-link>
                  <a @click="downloadFiles(form1datacopy.problemId,item)"><span
                      style="color: #3399ff;margin-left: 5px"> {{ item.fileName }}</span>
                  </a>
                  <a @click="remove1(form1datacopy.problemId, item.id)"><span
                      style="color: #3399ff;margin-left: 5px">删除</span>
                  </a>
                </div>
              </div>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="创建人：" prop="planStart">
              {{ form1datacopy.createUserName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="创建时间：" prop="planEnd">
              {{ form1datacopy.createDate }}
            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="submit('form1datacopy')" :loading="submitLoading">确定</Button>
        <Button class='ivu-btn-cancel' @click="handleCancel">取消</Button>
      </div>
    </Modal>
    <Modal title="选择审计项目" :transfer=false footer-hide v-model="tempSelectModal" :width=1000>
      <AuditTemplatePresetSelect ref="selTemplate" @getActivityData="getActivityData"
                                 @closeModal1="closeTemptSelectModal">
      </AuditTemplatePresetSelect>
    </Modal>
    <Modal title="图片查看" v-model="visible">
      <img :src="viewUrl" v-if="visible" style="width: 100%">
      <div slot="footer">
        <Button @click="visible=false" class='ivu-btn-save'>关闭</Button>
      </div>
    </Modal>
    <Modal title="指派整改" v-model="model2" :width=800>
      <Form ref="form1datacopy1" :model="form1datacopy" :rules="ruleCustomModel" :label-width="160">
        <Row type="flex" justify="space-around">
          <Col span="23">
            <FormItem label="审计任务：" prop="stdOrgName">
              {{ form1datacopy.missionName }}
            </FormItem>
          </Col>
        </Row>

        <Row type="flex" justify="space-around">
          <Col span="23">
            <FormItem label="审计单位：" prop="stdOrgName">
              {{ form1datacopy.auditedOrgName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around">
          <Col span="11">
            <FormItem label="组长：" prop="location">
              {{ form1datacopy.groupLeaderName }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="创建人：" prop="createUserId">
              {{ form1datacopy.createUserName }}
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around">
          <Col span="11">
            <FormItem label="开始时间：">
              {{ formatDate(new Date(form1datacopy.planStart), 'yyyy-MM-dd') }}
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="结束时间：">
              {{ formatDate(new Date(form1datacopy.planEnd), 'yyyy-MM-dd') }}
            </FormItem>
          </Col>

        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="11">
            <FormItem label="整改人：" prop="rectLeaderId">
              <Select class="query-form-el" v-model="form1datacopy.rectLeaderId" label-in-value
                      @on-change='rectLeaderChange'>
                <Option v-for="item in auditHandlers" :value="item.adtHandlerId" :key="item.adtHandlerId">
                  {{ item.adtHandlerName }}
                </Option>
              </Select>
            </FormItem>
          </Col>
          <Col span="11">
            <FormItem label="整改时间：" prop="rectTime">
              <DatePicker type="date" class="query-form-el" v-model="form1datacopy.rectTime" format="yyyy-MM-dd"
                          placeholder="请选择"></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row type="flex" justify="space-around" class="code-row-bg">
          <Col span="23">
            <FormItem label="整改要求：" prop="rectDesc">
              <Input v-model="form1datacopy.rectDesc" type="textarea" :rows="3"/>
            </FormItem>
          </Col>
        </Row>
      </Form>
      <div slot="footer">
        <Button class='ivu-btn-save' @click="submitMess('form1datacopy1')">确定</Button>
        <Button class='ivu-btn-cancel' @click="onCancel">取消</Button>
      </div>
    </Modal>
  </div>

</template>

<script>
import {Api} from '@/api/index.js'
import cascaderDom from '@/components/cascader-dom'
import {sessionStorage} from '@/common/cacheUtils.js'
import missionSelectForPro from "./missionSelectForPro.vue"
import AuditTemplatePresetSelect from "./AuditTemplatePresetSelect.vue"
import {compressImg, formatDate} from '@/tools/index'
import BenzAMRRecorder from 'benz-amr-recorder'

export default {
  components: {
    cascaderDom, missionSelectForPro, AuditTemplatePresetSelect
  },
  data() {

    const expectUserVal = (rule, value, callback) => {
      if (this.dataForm.expectUser !== null && this.dataForm.expectUser !== undefined) {
        callback();
      } else {
        callback(new Error(' '));
      }
    };
    const assignUserIdVal = (rule, value, callback) => {
      if (this.dataForm.assignUserId !== null && this.dataForm.assignUserId !== undefined) {
        callback();
      } else {
        callback(new Error(' '));
      }
    };

    return {
      auditMod: {auditName: "", finalScore: ""},
      filePercent: [],
      modaleshow: "1",
      add: true,
      audio: "",
      amr: null,
      misson: [],
      auditHandlers: [],
      model2: false,
      provideOrdId: '',
      switchFlag: false,
      model12: false,
      missonList: [],
      showdata: {},
      spanb: [],
      currentUser:sessionStorage('userId').getObject('userId'),
      auditList: [],
      expertSelectModal: false,
      tempSelectModal: false,
      fileUrl: Api.interestedPartiesUserFile,
      fileList:[],
      upLoadList1: [],
      form1datacopy: {},
      missionSelectModal: false,
      form1: {},
      dataForm: {},
      chkProblem: {},
      //分页参数
      submitLoading: false,
      pageSizeArray: [10, 20, 50],
      pagedata: {
        total: 0,
        pageSize: 10,
        currentPage: 1,
      },
      contentList: [],
      columns1: [

        {
          title: "序号",
          width: 80,
          align: "center",
          fixed: 'left',
          render: (h, params) => {
            return h('span', params.index + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
          }
        },
        /*{
          minWidth: 150,
          title: '审计任务',
          key: 'planTaskName',
          align: 'center'
        },*/
        /*  {
            minWidth: 150,
            title: '项目大类',
            key: 'categoryName',
            align: 'center',
            render: (h, params) => {
              return h('div', [
                h('span', params.row.categoryName || '--')
              ]);
            }
          },*/
        {
          minWidth: 150,
          title: '项目',
          key: 'categoryProjectName',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('span', params.row.categoryProjectName || '--')
            ]);
          }
        },
        // {
        //   minWidth: 150,
        //   title: '子项目',
        //   key: 'projectName',
        //   align: 'center',
        //   render: (h, params) => {
        //     return h('div', [
        //       h('span', params.row.projectName || '--')
        //     ]);
        //   }
        // },
        {
          minWidth: 150,
          title: '项目分值',
          key: 'projectScore',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('span', params.row.projectScore || '--')
            ]);
          }
        },
        {
          minWidth: 400,
          title: '审计内容',
          key: 'auditContent',
          align: 'center',
          render: (h, params) => {
            return h('div', [
              h('span', params.row.auditContent || '--')
            ]);
          }
        },
        {
          minWidth: 300,
          title: '问题描述',
          key: 'rpoblemDesc',
          align: 'center',
          slot: 'rpoblemDesc',
          tooltip: true,
        },
        /* {
           minWidth: 100,
           title: '审计专家',
           key: 'auditorName',
           align: 'center',
           render: (h, params) => {
             return h('div', [
               h('span', params.row.auditorName || '--')
             ]);
           }
         },*/
        {
          minWidth: 180,
          title: '扣分',
          key: 'auditScore',
          align: 'center',
          slot: 'auditScore',
        },
        {
          width: 120,
          title: '问题图片上传',
          key: 'img',
          align: 'center',
          slot: 'img',
          render: (h, {row, index}) => {
            return h("icon", {
              props: {
                type: 'md-eye',
                size: '20'
              },
              style: {
                cursor: 'pointer'
              },
              on: {
                click: () => {
                  this.form1datacopy = row;
                  this.form1datacopy.uploadList1 = [];
                  this.getFiles(this.form1datacopy.problemId);
                  this.modelupload = true;
                }
              }
            });
          }
        },
        {
          minWidth: 250,
          title: '问题图片',
          align: 'center',
          key: 'imgsrc',
          render: (h, params) => {
            if (params.row.pictureId) {
              let ps = params.row.pictureId.split(':')
              let hFn = []
              ps.forEach(v => {
                if (v) {
                  let url = this.fileUrl + '/file/' + v
                  hFn.push(
                      h('img', {
                        style: {
                          width: "30px",
                          margin: "3px",
                          cursor: "pointer"
                        },
                        attrs: {
                          src: url
                        },
                        on: {
                          click: () => {
                            this.handleView('', url)
                          }
                        }
                      })
                  )
                }
              })
              return h('div', [...hFn
              ]);
            } else {
              return h('div', '--')
            }

          }
        },
        {
          title: '操作',
          key: 'action',
          fixed: 'right',
          minWidth: 180,
          align: 'center',
          render: (h, params) => {
            let problemState = params.row.problemState
            return h('div', [
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '14px'
                },
                on: {
                  click: () => {
                    this.showData(params, 1);
                  }
                }
              }, '详情'),
              h('Divider', {
                props: {
                  type: 'vertical',
                }
              }, ''),
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '14px',
                },
                on: {
                  click: () => {
                    // this.showData(params, 2);
                    this.submits(params.row);

                  }
                }
              }, '确定'),
              h('Divider', {
                props: {
                  type: 'vertical',
                }
              }, ''),
              h('A', {
                props: {
                  type: 'primary',
                  size: 'small'
                },
                style: {
                  fontSize: '14px',
                  color: 'red',

                },
                on: {
                  click: () => {
                    this.deleteData(params);
                  }
                }
              }, '清空')
            ]);
          }
        }
      ],
      modelupload: false,
      ruleCustom: {
        auditScore: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.auditScore == null || this.form1datacopy.auditScore == '' || this.form1datacopy.auditScore == undefined) {
              callback(' ')
            } else if (value < 0) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        subitemId: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.subitemId == null || this.form1datacopy.subitemId == '' || this.form1datacopy.subitemId == undefined) {
              callback(' ')
            } else if (value < 0) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],

        factorName: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.factorName == null || this.form1datacopy.factorName == '' || this.form1datacopy.factorName == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],

        rpoblemDesc: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.rpoblemDesc == null || this.form1datacopy.rpoblemDesc == '' || this.form1datacopy.rpoblemDesc == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],

      },
      ruleCustomModel: {
        rectLeaderId: [
          {required: true, message: '  ', trigger: 'blur'}
        ],
        rectTime: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.rectTime == null || this.form1datacopy.rectTime == '' || this.form1datacopy.rectTime == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        rectDesc: [{
          validator: (rule, value, callback) => {
            if (this.form1datacopy.rectDesc == null || this.form1datacopy.rectDesc == '' || this.form1datacopy.rectDesc == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        auditedOrgId: [
          {required: true, message: '  ', trigger: 'change'}
        ],

        stdRankId: [
          {required: true, message: '  ', trigger: 'change'}
        ],
        groupLeaderName: [
          {required: true, message: '  ', trigger: 'change'}
        ],
        cover: [
          {required: true, message: '  ', trigger: 'change'}
        ],


        planEnd: [{
          validator: (rule, value, callback) => {
            if (value == null || value == '' || value == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],
        planStart: [{
          validator: (rule, value, callback) => {
            if (value == null || value == '' || value == undefined) {
              callback(' ')
            } else {
              callback()
            }
          },
          required: true,
          trigger: 'change'
        }],

      },
      contextCode: {},
      dataTable: [],
      model1: false,
      model11: false,
      missionModel: this.$route.query,
      buttonLoading: false,
      tableHeight: '',
      executorId: '',
      executorName: '',
      model3: false,
      viewForm: {},
      setCurrentExpectUserName: {},
      setCurrentAssignUserName: {},
      reportSelectAll: [],
      uploadList: [],
      uploadImgs: [],
      visible: false,
      viewUrl: Api.downloadPTWSchemeFile,
      upUrl: Api.uploadPTWFiles,
      editable: false,
    }
  },
  mounted: function () {

    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    // this.query();
    this.load();
  },


  methods: {
    getAuditDesc() {
      let _this = this;
      this.$http.get(Api.getAuditDesc + this.missionModel.missionId).then((res) => {
        _this.auditMod = res.data.data;
      }).catch((e) => {
        console.log(e)
      })
    },
    downloadFileRank() {
      this.$http.get(Api.downLoadAdtMission + this.missionModel.missionId, {
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = this.missionModel.auditedOrgName + "_" + "审计分值分布(" + formatDate(new Date(), "yyyy-MM-dd") + ").xlsx" //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    querySlect() {

      this.pagedata.currentPage = 1
      this.query();
    },
    lowerStep(name) {
      this.modaleshow = name
      this.load();
    },
    handleSpan({row, column, rowIndex, columnIndex}) {
      if (columnIndex === 2) {
        return {
          rowspan: row.mergeCol === 0 ? 0 : row.mergeCol,
          colspan: row.mergeCol === 0 ? 0 : 1
        };
      }
    },
    load() {
      if (this.modaleshow == '1') {
        this.executorId = this.missionModel.basicsId
        this.executorName = this.missionModel.basicsName
      } else if (this.modaleshow == '2') {
        this.executorId = this.missionModel.sceneId
        this.executorName = this.missionModel.sceneName
      } else {
        this.executorId = this.missionModel.teamId
        this.executorName = this.missionModel.teamName
      }
      this.query();
    },
    play(url, amr) {
      let _this = this;
      amr.onEnded(function () {
        _this.audio = "md-play"
      });
      if (amr.isInit()) {
        if (amr.isPlaying()) {
          amr.pause();
          this.audio = "md-play"
        } else {
          amr.play();

          this.audio = "md-square"
        }

      } else {

        amr.initWithUrl(url).then(function () {
          amr.play();
          _this.audio = "md-square"
        })
      }

    },
    back() {
      this.$router.push('/auditMission')
    },
    switchQuery(flag) {
      this.switchFlag = flag;
      if (this.switchFlag) {
        this.tableHeight = this.tableHeight - 44;
      } else {
        this.tableHeight = this.tableHeight + 44;
      }
    },
    downloadFiles(perfId, file) {
      let url = Api.interestedPartiesUserFile + '/file/' + file.id;
      this.$http.get(url, {
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = file.fileName //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    remoteMethod1(query) {
      this.misson = []
      for (var i = 0; i < this.missonList.length; i++) {
        if (this.missonList[i].missionName.indexOf(query + "") >= 0) {
          this.misson.push(this.missonList[i]);
        }
      }
    },
    submitMess(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          let userId = sessionStorage('userId').getObject('userId').userId;
          let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
          this.form1datacopy.createUsrId = userId;
          this.form1datacopy.createOrgId = orgId;

          this.$Modal.confirm({
            title: '指派整改确认',
            content: '<p>此操作无法撤销，请确认指派整改信息正确。</p>',
            okText: '确认',
            onOk: () => {
              this.form1datacopy.planTaskId = this.form1datacopy.missionId;
              this.$http.post(Api.createAdtProblemRect, this.form1datacopy).then((res) => {
                if (res.status === 200) {
                  this.$Message.success('指派成功');
                  this.model2 = false;
                  this.query()
                } else if (res.data.status === 201) {
                  this.$Message.error(res.data.msg);
                  this.model2 = false;
                }
              }).catch(e => {
                this.model2 = false;
                this.query();
                this.$Message.error("数据获取失败")
              })
            },
            cancelText: '取消'
          });
        } else {
          this.$Message.error('请填报完整!');
        }
      })
    },
    openExpertSelector(isLeader) {
      this.$refs.selExpert.isLeader = isLeader
      this.expertSelectModal = true;

    },
    missonListChange(val) {
      this.form1.planTaskId = val
      this.query();
    },
    downloadFileMod() {
      let missionId = this.missionModel.missionId
      let data = {
        missionId: missionId,
      }
      this.$http.get(Api.downloadAdtProblemMod, {
        params: data,
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = "审计标准裁剪导出(" + formatDate(new Date(), "yyyy-MM-dd") + ").xlsx" //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    selectCodingSort() {
      let id = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
      this.$http.get(Api.getAllTasksByUseId, {params: {id}}).then((res) => {
        this.missonList = res.data.data;
        if (this.missonList.length != 0) {
          this.form1.planTaskId = this.missonList[0].missionId;
          this.misson = this.missonList;
        }
        this.query();
      });

    },
    onCancel() {
      this.model3 = false
    },
    problemStateSelect(appStatus) {
      this.form1datacopy.problemState = appStatus && appStatus.value;
      this.form1datacopy.problemStateName = appStatus && appStatus.label;
    },
    getActivityExpertData(row) {
      this.form1.expertName = row.userName
      this.form1.expertId = row.userId
      this.expertSelectModal = false;
    },
    async getActivityData(row) {
      this.form1datacopy.factorId = row.id
      this.form1datacopy.factorName = row.projectName
      this.form1datacopy.executorId = row.executorId
      this.form1datacopy.factorScore = row.score
      this.form1datacopy.auditScore = 1
      if (row.type == '1') {
        this.form1datacopy.executorName = this.missionModel.basicsName;
      } else if (row.type == '2') {
        this.form1datacopy.executorName = this.missionModel.sceneName;
      } else if (row.type == '3') {
        this.form1datacopy.executorName = this.missionModel.teamName;
      }

      await this.selectByContent();
      this.tempSelectModal = false;
    },
    checkSubitemId(item) {
      console.log(item);
      this.form1datacopy.subitemId = item.value;
      this.form1datacopy.subitemName = this.contextCode[item.value];

    },
    async selectByContent() {
      let _this = this;
      await this.$http.get(Api.queryContentParentId + this.form1datacopy.factorId, {params: {}}).then((res) => {
        _this.contentList = res.data.data;
        if (_this.contentList.length != 0) {
          _this.contentList.forEach(item => {
            let key = item.id;
            _this.contextCode[key] = item.auditContent;
          })
        }
      });
    },
    openTempSelector() {
      if (this.form1datacopy.sceneId && this.form1datacopy.basicsId && this.form1datacopy.teamId) {
        this.tempSelectModal = true;
        this.$refs.selTemplate.init(this.form1datacopy.sceneId, this.form1datacopy.basicsId, this.form1datacopy.teamId);
      } else {
        this.$Message.warning("请选择审计任务！");
      }

    },
    closeExpertModal() {
      this.expertSelectModal = false;
    },
    closeTemptSelectModal() {
      this.tempSelectModal = false;
    },
    setUserName1(data) {
      this.form1datacopy.auditorName = data;
    },
    setUserId1(data) {
      this.form1datacopy.auditorId = data[data.length - 1];
    },
    reportSelect(select) {
      this.reportSelectAll = [];
      select.forEach(item => {
        this.reportSelectAll.push(item.problemId)
      });
    },
    submitReportSelect() {
      let _this = this;
      this.$http.post(Api.submitSelectAdtProblem, _this.reportSelectAll).then((res) => {
        if (res.data.status == '200') {
          _this.$Message.success("确认成功");
          _this.reportSelectAll = [];
          _this.query();
        } else {
          _this.$Message.success(res.data.msg);
          _this.query();
        }

      }).catch(e => {
        this.query();
        this.$Message.error("失败")
      })

    },
    selectMission(row) {
      this.missionSelectModal = false
      this.form1datacopy.planTaskName = row.missionName
      this.form1datacopy.planTaskId = row.missionId
      this.form1datacopy.auditedOrgName = row.auditedOrgName
      this.form1datacopy.auditedOrgId = row.auditedOrgId
      this.form1datacopy.problemState = '0'
      this.form1datacopy.problemStateName = '待确认'
      this.form1datacopy.auditorName = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
      this.form1datacopy.auditorId = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
      this.form1datacopy.sceneId = row.sceneId
      this.form1datacopy.teamId = row.teamId
      this.form1datacopy.basicsId = row.basicsId
      this.provideOrdId = row.auditedOrgId
      this.$refs.selTemplate.init(this.form1datacopy.sceneId, this.form1datacopy.basicsId, this.form1datacopy.teamId);
    },
    beforeUpload(file) {
      let keyID = Math.random().toString().substr(2);
      file['keyID'] = keyID;
      this.filePercent[this.fileList.length]=0;
      this.fileList.push(file);
      return false;
    },
    delectFile(name){
      this.fileList = this.fileList.filter(item => {
        return item.name != name
      })
    },
    handUpload(){
      var index = 0;
      var length = this.fileList.length;
      var _this = this;
      this.fileList.forEach(async(file,index)=>{
          let formData = new FormData();
          var config = {
            progress: function (e) {
              if(e.lengthComputable){
                _this.$set(_this.filePercent,index, 100 * (e.loaded / e.total));
              }
            }
          }
          var compressFile =await compressImg(file);
          formData.append("files", compressFile); // 文件对象
          let url = this.fileUrl + '/' + this.form1datacopy.problemId + '/files/picture/adtProblems'
          this.$http.post(url, formData,config).then((res) => {
            index++
            if (res.data.result == "success" && index == length) {
              this.$Message.info("文件上传成功")
              this.getFiles(this.form1datacopy.problemId);
              this.fileList = [];
              this.filePercent = [];
            }
          })
        })
    },
    async getFiles(id) {
      let _this = this;
      let url = this.fileUrl + '/' + id + '/files/picture'
      let data = {field: 'adtProblems'}
      await this.$http.get(url, {params: data}).then((res) => {
        if (res.data.result == "success") {
          if (res.data.data) {
            let updataList = res.data.data.map(v => {
              v.url = _this.fileUrl + '/file/' + v.id;
              return v
            })
            _this.$set(_this.form1datacopy, 'upLoadList1', updataList);

          }
        }
      })
    },
    async getAudio(id) {
      this.auditList = [];
      let url = this.fileUrl + '/' + id + '/files/audio'
      await this.$http.get(url).then((res) => {
        if (res.data.result == "success") {
          if (res.data.data) {
            this.auditList = res.data.data
            this.auditList = this.auditList.map(v => {
              v.url = this.fileUrl + '/file/' + v.id;
              return v
            })
          }
        }
      })
    },
    handleRemove(file) {
      //删除操作
      let _this = this;
      let config = {
        title: '系统提示',
        content: '确认删除图片吗?',
        okText: '确定',
        cancelText: '取消',
        onOk: function () {

          _this.$Spin.show({
            render: (h) => {
              return h('div', [
                h('Icon', {
                  'class': 'demo-spin-icon-load',
                  props: {
                    type: 'ios-loading',
                    size: 18
                  }
                }),
                h('div', 'Loading')
              ])
            }
          });
          _this.uploadImgs.splice(_this.uploadImgs.indexOf(file), 1);

          _this.$http.delete(Api.downloadPTWSchemeFile + '/' + file.id).then((res) => {
            _this.$Message.success('删除成功');
            /*  _this.uploadImgs = [];
              _this.$http.get(_this.upUrl, {params: {}}).then((res) => {
                  if(res.data.data!=null){
                      res.data.data.map((item)=>{
                          _this.uploadImgs.push({ name : item.fileName, id : item.id , url : Api.downloadPTWSchemeFile + '/' + item.id});
                      });
                  }
              }).catch(e => {
                  this.$Message.error("数据获取失败")
              })*/

            _this.$Spin.hide();
          }).catch(e => {
            _this.$Spin.hide();
            _this.$Message.error('删除失败' + e);
          })
        },
        onCancel: function () {
        }
      }
      this.$Modal.confirm(config);
    },
    openMissionSelectModal() {
      this.missionSelectModal = true
    },
    cellSpan(dataTable) {
      let contactDotb = 0;
      let spanb = [];
      dataTable.forEach((item, index) => {
        if (index === 0) {
          spanb.push(1)
        } else {
          if (item.projectName === this.dataTable[index - 1].projectName) {
            spanb[contactDotb] += 1;
            spanb.push(0)
          } else {
            contactDotb = index
            spanb.push(1)
          }
        }
      })
      this.spanb = spanb;
    },

    openSelect() {

      let userName = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
      this.form1datacopy = {
        auditTime: new Date(),
        planTaskName: this.missionModel.missionName,
        planTaskId: this.missionModel.missionId,
        auditedOrgName: this.missionModel.auditedOrgName,
        auditedOrgId: this.missionModel.auditedOrgId,
        problemState: '0',
        problemStateName: '待确认',
        auditorName: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
        auditorId: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"],
        sceneId: this.missionModel.sceneId,
        teamId: this.missionModel.teamId,
        basicsId: this.missionModel.basicsId,
        problemId: this.get_uuid(),
        auditScore: 1,
        createDate: this.formatDate(new Date(), 'yyyy-MM-dd'),
        createUserName: userName
      }
      this.model11 = true
      this.upLoadList1 = []
      this.add = true;
    },

    handleView(name, url) {
      this.viewUrl = url;
      this.imgName = name;
      this.visible = true;
    },

    handleCancel() {
      this.model1 = false;
      this.model11 = false;
      this.model12 = false;

    },
    rectLeaderChange(appStatus) {
      if (appStatus) {
        this.form1datacopy.rectLeaderId = appStatus.value;
        this.form1datacopy.rectLeader = appStatus.label;
      }
    },
    queryAdminMessage() {
      if (this.form1.planTaskId) {
        this.$http.post(Api.selectMissionById + this.form1.planTaskId).then((res) => {
          if (res.data.status === 200) {
            this.form1datacopy = res.data.data.adtMission;
            this.auditHandlers = res.data.data.auditHandlers;
            this.model2 = true;
          } else if (res.data.status == 202) {
            this.$Message.warning(res.data.msg)
          } else {
            this.$Message.error(res.data.msg)
          }

        }).catch(e => {
          this.$Message.error("指派失败")
        })
      } else {
        this.$Message.warning("请先选择审计任务！")
      }
    },
    addInfo() {
      this.dataForm = {};
      this.setCurrentExpectUserName = {};
      this.setCurrentAssignUserName = {
        label: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
        value: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"]
      };
      setTimeout(() => {
        //this.$refs.childUser1.setCurrentUser();
      }, 300);
      this.model1 = true;
    },

    setExpectUserName(data) {
      this.dataForm.expectUserName = data;
    },
    setExpectUserId(data) {
      this.dataForm.expectUser = data[data.length - 1];
    },

    setAssignUserName(data) {
      this.dataForm.assignUserName = data;
    },
    setAssignUserId(data) {
      this.dataForm.assignUserId = data[data.length - 1];
    },

    pageChange(pageNum) {
      this.pagedata.currentPage = pageNum;
      this.query();
    },
    pageSizeChange(pageSize) {
      this.pagedata.pageSize = pageSize;
      this.query();
    },
    submit(name) {
      let _this = this;
      this.$refs[name].validate((valid) => {
        if (valid) {
          let ids = ''
          if (this.upLoadList1) {
            this.upLoadList1.forEach(v => {
              ids += ":" + v.id
            })
          }

          this.submitLoading = true;
          if (this.add) {
            let userId = sessionStorage('userId').getObject('userId').userId;
            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
            this.form1datacopy.createUserId = userId;
            this.form1datacopy.createOrgId = orgId;
            this.form1datacopy.pictureId = ids
            this.$http.post(Api.createAdtProblem, this.form1datacopy).then((res) => {
              if (res.data.status == '200') {
                this.$Message.success('成功');
                this.model12 = false;
                this.query()

              } else if (res.data.status == '201') {
                this.$Message.error(res.data.data);
                this.model12 = false;
              } else if (res.data.status == '202') {
                this.$Message.error("扣分数累计超过最大分值新增失败");

              }
              _this.submitLoading = false;

            }).catch(e => {
              _this.submitLoading = false;
              this.model12 = false;
              this.query();
              this.$Message.error("数据获取失败")
            })
          } else {
            let userId = sessionStorage('userId').getObject('userId').userId;
            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
            this.form1datacopy.pictureId = ids
            this.form1datacopy.updateUserId = userId;
            this.form1datacopy.updateOrgId = orgId;
            this.$http.post(Api.updateAdtProblem, this.form1datacopy).then((res) => {
              if (res.data.status == '200') {
                this.$Message.success('成功');
                this.model12 = false;
                this.query()

              } else if (res.data.status == '201') {
                this.$Message.error(res.data.msg);
                this.model12 = false;
              } else if (res.data.status == '202') {
                this.$Message.error("扣分数累计超过最大分值修改失败");

              }
              _this.submitLoading = false;
            }).catch(e => {
              this.model12 = false;
              this.query();
              this.$Message.error("数据获取失败")
              _this.submitLoading = false;
            })
          }


        } else {
          this.$Message.error('请填报完整!');
        }
      })
    },
    isEmptyStrVal(value) {
      return value === undefined || value === null || /^\s*$/.test(value);
    },
    submits(data) {
      if (!this.isEmptyStrVal(data.rpoblemDesc)) {
        let _this = this;
        let ids = ''
        if (data.upLoadList1) {
          data.upLoadList1.forEach(v => {
            ids += ":" + v.id
          })
        }

        if (data.problemState == '0') {
          data.problemStateName = '待确认';
        } else {
          data.problemStateName = '已确认';
        }
        this.buttonLoading = true
        data.auditorName = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"];
        data.auditorId = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"];
        data.problemType = this.modaleshow;
        if (data.add) {
          let userId = sessionStorage('userId').getObject('userId').userId;
          let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
          let userName = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
          data.planTaskName = this.missionModel.missionName;
          data.planTaskId = this.missionModel.missionId;
          data.auditedOrgName = this.missionModel.auditedOrgName;
          data.auditedOrgId = this.missionModel.auditedOrgId;

          data.createDate = this.formatDate(new Date(), 'yyyy-MM-dd')
          data.createUserName = userName;
          data.createUserId = userId;
          data.createOrgId = orgId;
          data.pictureId = ids
          this.$http.post(Api.createAdtProblem, data).then((res) => {
            if (res.data.status == '200') {
              this.$Message.success('成功');
              this.query()
            } else if (res.data.status == '201') {
              this.$Message.error(res.data.data);
              _this.buttonLoading = false
            } else if (res.data.status == '202') {
              this.$Message.error("扣分数累计超过最大分值新增失败");
              _this.buttonLoading = false

            }

          }).catch(e => {
            _this.submitLoading = false;
            this.query();
            this.$Message.error("数据获取失败")
          })
        } else {
          data.auditTime = this.formatDate(new Date(data.auditTime), 'yyyy-MM-dd')
          let userId = sessionStorage('userId').getObject('userId').userId;
          let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
          data.pictureId = ids
          data.updateUserId = userId;
          data.updateOrgId = orgId;
          this.$http.post(Api.updateAdtProblem, data).then((res) => {
            if (res.data.status == '200') {
              this.$Message.success('成功');
              this.query()

            } else if (res.data.status == '201') {
              this.$Message.error(res.data.msg);
              _this.buttonLoading = false
            } else if (res.data.status == '202') {
              this.$Message.error("扣分数累计超过最大分值修改失败");
              _this.buttonLoading = false
            }
          }).catch(e => {
            this.query();
            this.$Message.error("数据获取失败")
            _this.submitLoading = false;
          })
        }
      } else {
        this.$Message.error("请输入内容后确定！")
      }

    },
    integratedData(data) {

      let that = this;
      // 获取所有的不同年龄值
      let arrId = [];
      data.forEach(i => {
        !arrId.includes(i.categoryId + i.projectId) ? arrId.push(i.categoryId + i.projectId) : arrId;
      });
      // 提前为每个年龄值设置跨行数为0
      let arrObj = [];
      arrId.forEach(j => {
        arrObj.push({
          id: j,
          num: 0
        })
      })
      // 计算每个年龄的可跨行数
      data.forEach(k => {
        arrObj.forEach(l => {
          k.categoryId + k.projectId === l.id ? l.num++ : l.num;
        })
      })
      data.forEach(m => {
        arrObj.forEach((n, index) => {
          if (m.categoryId + m.projectId === n.id) {
            if (arrId.includes(m.categoryId + m.projectId)) {
              m.mergeCol = n.num;
              arrId.splice(arrId.indexOf(m.categoryId + m.projectId), 1);
            } else {
              m.mergeCol = 0;
            }
          }
        })
      })
      return data;
    },
    query() {
      this.buttonLoading = true
      let data = {
        currentPage: this.pagedata.currentPage,
        size: this.pagedata.pageSize,
        id: this.missionModel.missionId,
        executorId: this.executorId,
        executorName: this.executorName,
      }
      if (this.form1.planTaskId) {
        data.planTaskId = this.form1.planTaskId
      }

      if (this.form1.rpoblemDesc) {
        data.rpoblemDesc = this.form1.rpoblemDesc
      }
      if (this.form1.problemState) {
        data.problemState = this.form1.problemState
      }
      if (this.form1.expertId) {
        data.auditorId = this.form1.expertId
      }

      data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
      let url = Api.findMissionId;
      let _this = this;
      this.getAuditDesc();
      this.$http.get(url, {params: data}).then((res) => {
        this.dataTable = _this.integratedData(res.data.data.data);
        this.pagedata.total = res.data.data.totalSize;
        this.buttonLoading = false

      }).catch(e => {
        this.buttonLoading = false
        this.$Message.error("数据获取失败")
      })
    },
    reset() {
      this.form1 = {};
      this.querySlect();
    },

    deleteData(params) {
      let url = Api.deleteAdtProblem;

      this.$Modal.confirm({
        title: '数据清空',
        content: '<p>确定清空该条审计问题吗？</p>',
        okText: '确认',
        onOk: () => {
          this.$http.get(url, {params: {id: params.row.problemId}}).then((res) => {
            if (res.status === 200) {
              this.$Message.success('成功');
              this.query()
            } else if (res.data.status === 201) {
              this.$Message.error(res.data.msg);

            }
          }).catch(e => {
            this.$Message.error('请求失败' + e);
          })
        },
        cancelText: '取消'
      });
    },
    formatDate(date, fmt) {
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
      }
      let o = {
        'M+': date.getMonth() + 1,
        'd+': date.getDate(),
        'h+': date.getHours(),
        'm+': date.getMinutes(),
        's+': date.getSeconds()
      };
      for (let k in o) {
        if (new RegExp(`(${k})`).test(fmt)) {
          let str = o[k] + '';
          fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
        }
      }
      return fmt;
    },
    padLeftZero(str) {
      return ('00' + str).substr(str.length);
    },
    downloadFile() {
      let data = {
        sceneId: this.missionModel.sceneId,
        basicsId: this.missionModel.basicsId,
        teamId: this.missionModel.teamId,
        missionId: this.missionModel.missionId,
        auditedOrgName: this.missionModel.auditedOrgName
      }
      data = Object.assign(data, JSON.parse(JSON.stringify(this.form1)));
      this.$http.get(Api.downloadAdtProblem, {
        params: data,
        responseType: 'blob'      //告诉服务器我们需要的响应格式
      }).then((res) => {
        const aLink = document.createElement("a");
        let blob = new Blob([res.data], {
          type: res.bodyBlob.type      //将会被放入到blob中的数组内容的MIME类型
        });
        aLink.href = URL.createObjectURL(blob)
        aLink.download = "审计问题清单(" + formatDate(new Date(), "yyyy-MM-dd") + ").xlsx" //标题
        aLink.click()
        document.body.appendChild(aLink)
      })
    },
    get_uuid() {
      let s = [];
      let hexDigits = "0123456789abcdef";
      for (let i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
      }
      s[14] = "4";
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
      s[8] = s[13] = s[18] = s[23] = "-";

      let uuid = s.join("");
      let reg = new RegExp("-", "g");
      let a = uuid.replace(reg, "");
      return a;
    },
    remove1(mainId, id) {
      let url = this.fileUrl + '/file/' + id;
      this.$http.delete(url).then((res) => {
        var index = this.upLoadList1.indexOf(id);
        if (index > -1) {
          this.upLoadList1.splice(index, 1);
        }
        this.getFiles(mainId)
      })
    },
    async showData(data, flag) {
      let _this = this
      data.row.createDate = data.row.createDate ? this.formatDate(new Date(data.row.createDate), 'yyyy-MM-dd') : '';
      this.getFiles(data.row.problemId)
      if (flag == 1) {
        if (data.row.problemId) {
          this.showdata = data.row;
          await this.getAudio(data.row.problemId);
          this.showdata.amr = new BenzAMRRecorder();
          this.audio = "md-play";

        } else {
          this.showdata = {
            planTaskName: this.missionModel.missionName,
            planTaskId: this.missionModel.missionId,
            auditedOrgName: this.missionModel.auditedOrgName,
            auditedOrgId: this.missionModel.auditedOrgId,
            factorId: data.row.projectId,
            factorName: data.row.projectName,
            executorId: this.executorId,
            executorName: this.executorName,
            subitemId: data.row.contentId,
            subitemName: data.row.auditContent,
            factorScore: data.row.projectScore,

          }
        }
        this.model3 = true;
      } else {
        if (data.row.problemId) {
          this.add = false;
          this.form1datacopy.factorId = data.row.factorId
          await this.selectByContent();
          this.form1datacopy = JSON.parse(JSON.stringify(data.row));
          this.form1datacopy.auditTime = this.formatDate(new Date(this.form1datacopy.auditTime), 'yyyy-MM-dd')
        } else {
          this.add = true;
          let userName = JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"]
          this.form1datacopy = {
            auditTime: new Date(),
            factorId: data.row.projectId,
            factorName: data.row.projectName,
            executorId: this.executorId,
            executorName: this.executorName,
            subitemId: data.row.contentId,
            subitemName: data.row.auditContent,
            factorScore: data.row.projectScore,


            planTaskName: this.missionModel.missionName,
            planTaskId: this.missionModel.missionId,
            auditedOrgName: this.missionModel.auditedOrgName,
            auditedOrgId: this.missionModel.auditedOrgId,
            problemState: '0',
            problemStateName: '待确认',
            auditorName: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserName"],
            auditorId: JSON.parse(sessionStorage('paramUserInfo').get('userInfo'))["createUserId"],
            problemId: this.get_uuid(),
            auditScore: 1,
            createDate: this.formatDate(new Date(), 'yyyy-MM-dd'),
            createUserName: userName

          }
          this.upLoadList1 = []
        }

        this.model12 = true;


      }
    },
  },

  watch: {},

}
</script>
<style lang='css' scoped>
@import '../../../index.css';

.aR {
  text-align: right;
}

.fixed:after {
  display: block;
  content: '';
  clear: both;
  width: 100%;
  height: 0;
}

.self-check-form {
}

/deep/ .self-check-form .ivu-form-item {
  /*margin-bottom: 24px;*/
}

/deep/ .self-check-form .ivu-table-wrapper {
  overflow: visible;
}

/deep/ .self-check-form .ivu-table-wrapper .ivu-table {
  overflow: visible;
}

.demo-upload-list {
  display: inline-block;
  width: 60px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
  margin-right: 4px;
}

.demo-upload-list img {
  width: 100%;
  height: 100%;
}

.demo-upload-list-cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, .6);
}

.demo-upload-list:hover .demo-upload-list-cover {
  display: block;
}

.demo-upload-list-cover i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  margin: 0 2px;
}
</style>
